//
//  SchoolDetailCalendarHeadView.m
//  Arts1
//
//  Created by 孤星晨宇 on 15/10/7.
//  Copyright © 2015年 Arts1. All rights reserved.
//

#import "SchoolDetailCalendarHeadView.h"
#import "AllHeader.h"

@implementation SchoolDetailCalendarHeadView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
//        [UIView viewWideForShadowColor:self];
        
        [self addSubview:self.backButton];
        [self addSubview:self.titleLabel];
        [self addSubview:self.subTitlelabel];
        [self addSubview:self.shareBTN];
        
        [self addSubview:self.lineView];
        
        [self addSubview:self.timeLabel];
        [self addSubview:self.calendar];
        
        [self createLeftImageView];
        [self createRightImageView];
    }
    return self;
}

- (UIButton *)backButton{
    if (!_backButton) {
        _backButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _backButton.frame = CGRectMake(8, 6, 28 , 28);
        [_backButton setImage:[UIImage imageNamed:@"backButton"] forState:(UIControlStateNormal)];
    }
    return _backButton;
}

- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 5, SCREEN_WIDTH - 100, 17)];
//        _titleLabel.text = @"中央美术学院";
        _titleLabel.textColor = lFONTCOLOR;
        _titleLabel.font = [UIFont boldSystemFontOfSize:16];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}

- (UILabel *)subTitlelabel{
    if (!_subTitlelabel) {
        _subTitlelabel = [[UILabel alloc] initWithFrame:CGRectMake(50, _titleLabel.bottom + 2, SCREEN_WIDTH - 100, 11)];
//        _subTitlelabel.text = @"北京";
        _subTitlelabel.textColor = sFONTCOLOR;
        _subTitlelabel.font = [UIFont boldSystemFontOfSize:12];
        _subTitlelabel.textAlignment = NSTextAlignmentCenter;
    }
    return _subTitlelabel;
}


- (UIButton *)shareBTN{
    if (!_shareBTN) {
        _shareBTN = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _shareBTN.frame = CGRectMake(SCREEN_WIDTH - 44, 3, 34 , 34);
        [_shareBTN setImage:[UIImage imageNamed:@"share"] forState:(UIControlStateNormal)];
        [_shareBTN setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    }
    return _shareBTN;
}


- (UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 44, SCREEN_WIDTH, 0.5)];
        _lineView.backgroundColor = kCustomColor(150, 150, 150, 0.5);
    }
    return _lineView;
}


- (UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 2.0 - 30, 60, 60 , 11)];
        _timeLabel.text = @"考试时间";
        _timeLabel.font = [UIFont systemFontOfSize:12];
        _timeLabel.textColor = kCustomColor(150, 150, 150, 1);
        _timeLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _timeLabel;
}

- (UIButton *)calendar{
    if (!_calendar) {
        _calendar = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _calendar.frame = CGRectMake(SCREEN_WIDTH - 94, 54, 84 , 28);
        [_calendar setTitle:@"添加至日历" forState:(UIControlStateNormal)];
        _calendar.backgroundColor = kCustomColor(50, 50, 70, 1);
        _calendar.layer.cornerRadius = 4;
        _calendar.titleLabel.font = [UIFont systemFontOfSize:14];
        _calendar.layer.masksToBounds = YES;
    }
    return _calendar;
}

- (void)createLeftImageView{
    UIImageView *leftView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 50, 34, 34)];
    leftView.backgroundColor = [UIColor orangeColor];
    leftView.image = [UIImage imageNamed:@"timeImage"];
    leftView.layer.cornerRadius = 17;
    leftView.layer.masksToBounds = YES;
    [self addSubview:leftView];
    
    _ltLabel = [[UILabel alloc] initWithFrame:CGRectMake(2, 3, 18,18)];
    _ltLabel.textAlignment = NSTextAlignmentCenter;
    _ltLabel.font = [UIFont systemFontOfSize:13];
    _ltLabel.textColor = [UIColor whiteColor];
    [leftView addSubview:_ltLabel];

    _lbLabel = [[UILabel alloc] initWithFrame:CGRectMake(16.5, 13, 18,18)];
    _lbLabel.textAlignment = NSTextAlignmentCenter;
    _lbLabel.font = [UIFont boldSystemFontOfSize:11];
    _lbLabel.textColor = [UIColor whiteColor];
    [leftView addSubview:_lbLabel];
    
    UIImageView *lineView = [[UIImageView alloc] initWithFrame:CGRectMake(53, 62.5, 19,9)];
//    lineView.backgroundColor = [UIColor redColor];
    lineView.image = [UIImage imageNamed:@"timeLine"];
    
    [self addSubview:lineView];
    
}

- (void)createRightImageView{
    UIImageView *rightView = [[UIImageView alloc] initWithFrame:CGRectMake(82, 50,34, 34)];
    rightView.backgroundColor = [UIColor orangeColor];
    rightView.image = [UIImage imageNamed:@"timeImage"];
    rightView.layer.cornerRadius = 17;
    rightView.layer.masksToBounds = YES;
    [self addSubview:rightView];
    
    _rtLabel = [[UILabel alloc] initWithFrame:CGRectMake(2, 3, 18,18)];
    _rtLabel.textAlignment = NSTextAlignmentCenter;
    _rtLabel.font = [UIFont systemFontOfSize:13];
    _rtLabel.textColor = [UIColor whiteColor];
    [rightView addSubview:_rtLabel];
    
    _rbLabel = [[UILabel alloc] initWithFrame:CGRectMake(16.5, 13, 18,18)];
    _rbLabel.textAlignment = NSTextAlignmentCenter;
    _rbLabel.font = [UIFont boldSystemFontOfSize:11];
    _rbLabel.textColor = [UIColor whiteColor];
    [rightView addSubview:_rbLabel];

}


- (void)setContent:(SpaceContentModel *)content {
    _content = content;
    _titleLabel.text = _content.spaceName;
    _subTitlelabel.text = _content.title;
    if (_content.startdate) {
        NSArray *leftArr = [_content.startdate  componentsSeparatedByString:@"-"];
        _ltLabel.text = leftArr[2];
        _lbLabel.text = leftArr[1];
    }
   
    if (_content.enddate) {
        NSArray *rightArr = [_content.enddate componentsSeparatedByString:@"-"];
        _rtLabel.text = rightArr[2];
        _rbLabel.text = rightArr[1];
    }
    
    
}





/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
